package com.renbang.action.art;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.renbang.model.common.AjaxResult;
import com.renbang.model.common.Page;
import com.renbang.model.art.ArtOrder;
import com.renbang.service.art.ArtOrderService;
import com.renbang.action.BaseAction;
/**
 * 该代码由程序生成
 */
@Controller
@RequestMapping(value = "user/art/ArtOrder")
public class ArtOrderAction  extends BaseAction<ArtOrder>{
	@Autowired
	ArtOrderService artOrderService;
	
	
	//打开新增或修改页面
	@RequestMapping(value = "/editForm")
	public String editForm(Integer id, HttpServletRequest request) {
		ArtOrder artOrder;
		if (id != null) {
			artOrder = artOrderService.findById(id);
			request.setAttribute("obj", artOrder);
		}
		return "user/art/ArtOrder-form";
	}
	@RequestMapping(value = "/addOrModify")
	public  @ResponseBody AjaxResult insertOrUpdata(HttpServletRequest request,
	ArtOrder artOrder) {
		if(artOrder.getId()!=null){
			int i = artOrderService.modify(artOrder);
			if (i > 0)
				return new AjaxResult(AjaxResult.STATUS_OK, "修改成功");
			else
				return new AjaxResult(AjaxResult.STATUS_OK, "修改失败");
	} else {
		 int i = artOrderService.add(artOrder);
		 if (i > 0)
		 	return new AjaxResult(AjaxResult.STATUS_OK, "增加成功");
		 else
			return new AjaxResult(AjaxResult.STATUS_OK, "增加失败");
	}
		
	}
	
}
